#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <iterator>
#include <string>
#include <sstream>
#include <vector>
#include <list>

double gauss(double x)
{
    const static double sqrt2pi = 2.5066282746310002;
    return exp( - x * x ) / sqrt2pi;
}

int main(int argc, char** argv)
{
    using namespace std;

    string fileName(argv[1]);
        
    double scope = 3.0;
    double size = 1 * 1024 * 1024 * 1024 / 64; // 512MB
    
    ofstream out(fileName.c_str());
    
    double dx = sqrt(1.0 / size);
    
    list<double> rsltList;
    
    for (double x = - scope; x < scope; x += dx)
    {
        double ymax = gauss(x);
        
        for(double y = 0; y < ymax; y += dx)
        {
            rsltList.push_back(x);
        }
        
        cout << x << " ";
    }
    
    vector<double> rslt(rsltList.size());
    
    copy(rsltList.begin(), rsltList.end(), rslt.begin());
    
    random_shuffle(rslt.begin(), rslt.end());
    
    copy(rslt.begin(), rslt.end(), ostream_iterator<double>(out, " "));
}
